
var delivery_error_vm = avalon.define({
    $id: 'delivery-error',
    is_display_detail: false,
    need_change: true,
    lines: [],

    display_detail: function(picking_id) {
        if (delivery_error_vm.lines.length == 0) {
            $.ajax({
                url: '/weixin/delivery/get_lines',
                data: {picking_id: picking_id},
                success: function(e) {
                    delivery_error_vm.lines = JSON.parse(e);
                },
                type: 'get',
                async: true,
            });
        };
        delivery_error_vm.is_display_detail = !delivery_error_vm.is_display_detail;
    }, 

    change_user: function() {
        $.ajax({
            url: '/weixin/delivery/change_user',
            data: { picking_id: $('#hidden_picking').val(), user_id: $('#hidden_user').val() },
            success: function(e) {
                delivery_error_vm.need_change = false;
            },
            type: 'post',
            async: true,
        });
    },
});